import { trans } from '@utils/common'
import { post, get, postL, getL } from '@utils/http'
import { SERVE_URL } from '@utils/config'

export default {
    apis: {
        //=================商户================
        COMPANY_ALL: SERVE_URL + 'apiExp/merchant/company/dropDownList',
        COMPANY_LIST: SERVE_URL + 'apiExp/merchant/company/pageQuery',
        COMPANY_EDIT: SERVE_URL + 'apiExp/merchant/company/edit', //修改商户
        COMPANY_SAVE: SERVE_URL + 'apiExp/merchant/company/save', //添加商户
        COMPANY_DELETE: SERVE_URL + 'apiExp/manager/sysCompany/del',
        COMPANY_DISABLED: SERVE_URL + 'apiExp/merchant/company/disable', //禁用商户
        COMPANY_ENABLE: SERVE_URL + 'apiExp/merchant/company/enable', //禁用商户
        COMPANY_DETAIL: SERVE_URL + 'apiExp/merchant/company/detail', //商户详情

        COMPANY_RATE_EDIT: SERVE_URL + 'apiExp/merchant/company/setProfitRate', //单个编辑分成
        COMPANY_RATES_EDIT: SERVE_URL + 'apiExp/merchant/company/setProfitRates', //批量修改分成
        COMPANY_RATE_LIST: SERVE_URL + 'apiExp/businessOperations/profitRate/profitPageQuery', //分成记录
        COMPANY_RATE_RISKRATE: SERVE_URL + 'apiExp/merchant/company/setRiskRate', //风控设置
        COMPANY_RATE_RISKRATES: SERVE_URL + 'apiExp/merchant/company/setRiskRates', //批量风控设置
        PLATFORM_EDIT_PLATFORMRISK: SERVE_URL + 'apiExp/merchant/platform/editPlatformRisk', //平台管理风控设置

        //=================平台================
        COMPANY_LIST_BYREALLY: SERVE_URL + 'apiExp/merchant/platform/getPlatformRisk',

        //================菜单=================
        MENU_LIST: SERVE_URL + 'apiExp/manager/sysMenu/list', // 菜单查询
        MENU_TREE: SERVE_URL + 'apiExp/manager/sysMenu/tree', // 上级菜单
        MENU_DELETE: SERVE_URL + 'apiExp/manager/sysMenu/del', // 菜单 删除
        MENU_SAVE: SERVE_URL + 'apiExp/manager/sysMenu/save', // 菜单 新增
        MENU_EDIT: SERVE_URL + 'apiExp/manager/sysMenu/update', // 菜单 修改

        //===============部门===================
        DEPT_LIST: SERVE_URL + 'apiExp/manager/sysDepart/listAll',
        DEPT_TREE: SERVE_URL + 'apiExp/manager/sysDepart/tree',
        DEPT_DELETE: SERVE_URL + 'apiExp/manager/sysDepart/del',
        DEPT_EDIT: SERVE_URL + 'apiExp/manager/sysDepart/save',

        //=================岗位================
        STATION_ALL: SERVE_URL + 'apiExp/manager/sysStation/listAll',
        STATION_LIST: SERVE_URL + 'apiExp/manager/sysStation/list',
        STATION_EDIT: SERVE_URL + 'apiExp/manager/sysStation/save',
        STATION_DELETE: SERVE_URL + 'apiExp/manager/sysStation/del',

        //=================角色================
        ROLE_ALL: SERVE_URL + 'apiExp/manager/sysRole/listAll',
        ROLE_LIST: SERVE_URL + 'apiExp/manager/sysRole/list',
        ROLE_EDIT: SERVE_URL + 'apiExp/manager/sysRole/save',
        ROLE_DELETE: SERVE_URL + 'apiExp/manager/sysRole/del',

        //===============用户组===============
        GROUP_ALL: SERVE_URL + 'apiExp/manager/sysGroup/listAll',
        GROUP_LIST: SERVE_URL + 'apiExp/manager/sysGroup/list',
        GROUP_EDIT: SERVE_URL + 'apiExp/manager/sysGroup/save',
        GROUP_DELETE: SERVE_URL + 'apiExp/manager/sysGroup/del',

        //===============用户===============
        USER_LIST: SERVE_URL + 'apiExp/manager/sysUser/pageQuery', // 用户管理用户列表
        USER_SAVE: SERVE_URL + 'apiExp/manager/sysUser/save', // 用户管理 新增
        USER_EDIT: SERVE_URL + 'apiExp/manager/sysUser/updateByUserName', // 用户管理 修改
        USER_DELETE: SERVE_URL + 'apiExp/manager/sysUser/del', // 用户管理 删除
        USER_RESET_PWD: SERVE_URL + 'apiExp/manager/sysUser/resetPwd', // 用户管理 重置密码

        //组织架构 -机构管理
        ORG_PAGE: SERVE_URL + 'apiExp/manager/org/pageQuery',
        OSYSORG_TREE: SERVE_URL + 'apiExp/manager/sysOrg/tree',
        ORG_UPDATE: SERVE_URL + 'apiExp/manager/org/update',//启用关闭
        ORG_DELETE: SERVE_URL + 'apiExp/manager/org/delete',
        //组织架构 - 机构组别
        ORGGROUP_PAGE: SERVE_URL + 'apiExp/manager/orgGroup/pageQuery',
        ORGGROUP_UPDATE: SERVE_URL + 'apiExp/manager/orgGroup/update',
        SYSDIRECT_LISTBYCODE: SERVE_URL + 'apiExp/manager/sysDict/listByCode',
        ORGGROUP_DELETE: SERVE_URL + 'apiExp/manager/orgGroup/delete',
        ORGGROUP_SAVE: SERVE_URL + 'apiExp/manager/orgGroup/save',
        // 角色管理
        ROLE_PAGE: SERVE_URL + 'apiExp/manager/role/pageQuery',
        ROLE_UPDATE: SERVE_URL + 'apiExp/manager/role/update',
        ROLE_SAVE: SERVE_URL + 'apiExp/manager/role/save',
        ROLE_DELETE: SERVE_URL + 'apiExp/manager/role/delete',
        ROLE_DATA: SERVE_URL + 'apiExp/manager/role/data',
        ROLE_MENU: SERVE_URL + 'apiExp/manager/role/menu',
    },

    async companyAll(param) {
        let data = { ...param};
        data.excludePlatforms = data.excludePlatforms ==false?data.excludePlatforms:true;
        // param.excludePlatforms = true;
        const res = await trans(get(this.apis.COMPANY_ALL, data));
        return res.data;
    },

    async companys(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.COMPANY_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    async companysByreally(param) {
        const res = await trans(post(this.apis.COMPANY_LIST_BYREALLY, param));
        return res.data;
    },

    async companyEdit(param) {
        const res = await trans(postL(this.apis.COMPANY_EDIT, param));
        return res.success;
    },
    async companySave(param) {
        const res = await trans(postL(this.apis.COMPANY_SAVE, param));
        return res.success;
    },

    async companyDisable(companyId) {
        const res = await trans(getL(this.apis.COMPANY_DISABLED, { companyId }));
        return res.success;
    },
    async companyEnable(companyId) {
        const res = await trans(getL(this.apis.COMPANY_ENABLE, { companyId }));
        return res.success;
    },
    async companyDetail(companyId) {
        const res = await trans(getL(this.apis.COMPANY_DETAIL, { companyId }));
        return res;
    },

    async companyRates(pageNo, pageSize = 20, param) {
        const res = await trans(
            postL(this.apis.COMPANY_RATE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize, orderByColumn: 'createTime', orderDirection: 'desc' },
            })
        );
        return res;
    },

    async companyRateEdit(param) {
        const res = await trans(postL(this.apis.COMPANY_RATE_EDIT, param));
        return res.success;
    },
    async companyRateEdits(param) {
        const res = await trans(postL(this.apis.COMPANY_RATES_EDIT, param));
        return res.success;
    },
    async configRiskRate(param) {
        const res = await trans(postL(this.apis.COMPANY_RATE_RISKRATE, param));
        return res.success;
    },
    async platformEditPlatformrisk(param) {
        const res = await trans(postL(this.apis.PLATFORM_EDIT_PLATFORMRISK, param));
        return res.success;
    },
    async configRiskRates(param) {
        const res = await trans(postL(this.apis.COMPANY_RATE_RISKRATES, param));
        return res.success;
    },
    async menus() {
        const res = await trans(post(this.apis.MENU_LIST));
        if (res.data) {
            res.data = res.data.filter(item => item.id != -1);
        }
        return res.data;
    },

    async menuTree() {
        const res = await trans(post(this.apis.MENU_TREE));
        return res.data;
    },

    async menuDelete(id) {
        const res = await trans(getL(this.apis.MENU_DELETE, { id }));
        return res.success;
    },

    // 菜单新增
    async menuSave(param) {
        const res = await trans(postL(this.apis.MENU_SAVE, param));
        return res.data;
    },
    // 菜单修改
    async menuEdit(param) {
        const res = await trans(postL(this.apis.MENU_EDIT, param));
        return res.data;
    },

    async depts(param) {
        const res = await trans(post(this.apis.DEPT_LIST, param));
        if (res.data) {
            res.data = res.data.filter(item => item.id != -1);
        }
        return res.data;
    },

    async deptTree(param) {
        const res = await trans(post(this.apis.DEPT_TREE, param));
        return res.data;
    },

    async deptDelete(ids) {
        const res = await trans(getL(this.apis.DEPT_DELETE, { ids }));
        return res.success;
    },

    async deptEdit(param) {
        const res = await trans(postL(this.apis.DEPT_EDIT, param));
        return res.data;
    },

    async stationAll(param) {
        const res = await trans(post(this.apis.STATION_ALL, param));
        return res.data;
    },
    async stations(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.STATION_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async stationEdit(param) {
        const res = await trans(postL(this.apis.STATION_EDIT, param));
        return res.success;
    },

    async stationDelete(ids) {
        const res = await trans(getL(this.apis.STATION_DELETE, { ids }));
        return res.success;
    },

    async roleAll(param) {
        const res = await trans(post(this.apis.ROLE_ALL, param));
        return res.data;
    },

    async roles(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.ROLE_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    async roleEdit(param) {
        const res = await trans(postL(this.apis.ROLE_EDIT, param));
        return res.success;
    },

    async roleDelete(id) {
        const res = await trans(post(this.apis.ROLE_DELETE, { id }));
        return res.success;
    },

    async groupAll(param) {
        const res = await trans(post(this.apis.GROUP_ALL, param));
        return res.data;
    },

    async groups(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.GROUP_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res.data;
    },

    async groupEdit(param) {
        const res = await trans(postL(this.apis.GROUP_EDIT, param));
        return res.success;
    },

    async groupDelete(ids) {
        const res = await trans(getL(this.apis.GROUP_DELETE, { ids }));
        return res.success;
    },

    async users(pageNo, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.USER_LIST, {
                bo: { ...param },
                page: { currentPage: pageNo, pageSize: pageSize },
            })
        );
        return res;
    },

    // 用户管理 新增
    async userSave(param) {
        const res = await trans(postL(this.apis.USER_SAVE, param));
        return res.success;
    },

    // 用户管理 修改
    async userEdit(param) {
        const res = await trans(postL(this.apis.USER_EDIT, param));
        return res.success;
    },
    // 用户管理 删除
    async userDelete(id) {
        const res = await trans(getL(this.apis.USER_DELETE, { id }));
        return res.success;
    },

    // 用户管理 重置密码
    async userResetPwd(userId) {
        const res = await trans(postL(this.apis.USER_RESET_PWD + '?id=' + userId));
        return res.success;
    },

    // 组织架构
    async orgPage(currentPage, pageSize = 20, param) {
        const res = await trans(
            postL(this.apis.ORG_PAGE, {
                bo: { ...param },
                page: { currentPage: currentPage, pageSize: pageSize },
            })
        );
        return res;
    },
    async osysorgTree() {
        const res = await trans(getL(this.apis.OSYSORG_TREE, {}));
        return res;
    },
    async orgUpdate(param) {
        const res = await trans(post(this.apis.ORG_UPDATE, param));
        return res;
    },
    async orgDelete(param) {
        const res = await trans(post(this.apis.ORG_DELETE, param));
        return res;
    },
    async orgGroupPage(currentPage, pageSize = 20, param) {
        const res = await trans(
            postL(this.apis.ORGGROUP_PAGE, {
                bo: { ...param },
                page: { currentPage: currentPage, pageSize: pageSize },
            })
        );
        return res;
    },
    async orgGroupPageUpdate(param) {
        const res = await trans(post(this.apis.ORGGROUP_UPDATE, param));
        return res;
    },
    async orgGroupPageSave(param) {
        const res = await trans(post(this.apis.ORGGROUP_SAVE, param));
        return res;
    },
    async orgGroupPageDelete(param) {
        const res = await trans(post(this.apis.ORGGROUP_DELETE, param));
        return res;
    },
    async sysdirectListbyCode(param) {
        const res = await trans(post(this.apis.SYSDIRECT_LISTBYCODE, param));
        return res.data;
    },
    async rolePage(currentPage, pageSize = 20, param) {
        const res = await trans(
            post(this.apis.ROLE_PAGE, {
                bo: { ...param },
                page: { currentPage: currentPage, pageSize: pageSize },
            })
        );
        return res;
    },
    async roleUpdate(param) {
        const res = await trans(post(this.apis.ROLE_UPDATE, param));
        return res;
    },
    async roleSave(param) {
        const res = await trans(post(this.apis.ROLE_SAVE, param));
        return res;
    },
    async roleData(param) {
        const res = await trans(post(this.apis.ROLE_DATA, param));
        return res;
    },
    async roleMenu(param) {
        const res = await trans(post(this.apis.ROLE_MENU, param));
        return res;
    },
};
